
#include <iostream>

#include <QApplication>
#include <QPushButton>
#include <QFile>
#include <QUrl>
#include <QList>
#include "dashwidget.h"

static QFile dbg("/dev/stderr");

DashWidget::DashWidget(QWidget *parent)
  : QWidget(parent)
{
  setAcceptDrops(true);
  setFixedSize(200, 600);

  //QPushButton *quit = new QPushButton(tr("Quit"), this);
  //quit->setGeometry(62, 40, 75, 30);
  //quit->setFont(QFont("Times", 18, QFont::Bold));

  //connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
}

void DashWidget::dragEnterEvent(QDragEnterEvent *event)
{
  
  //if (event->mimeData()->hasFormat("text/plain"))
    event->acceptProposedAction();
}

void DashWidget::dropEvent(QDropEvent *event)
{
  //textBrowser->setPlainText(event->mimeData()->text());
  //mimeTypeCombo->clear();
  //mimeTypeCombo->addItems(event->mimeData()->formats());
  std::cout << event->mimeData()->formats().join(" ").toAscii().constData() << std::endl;
  //qDebug(event->mimeData()->data("message/rfc822"));
  qDebug( "%i\n", event->mimeData()->data("x-kmail-drag/message-list").size() );
    qDebug( "%s\n", event->mimeData()->data("x-kmail-drag/message-list").constData() );
  if ( event->mimeData()->hasUrls() )
  {
    qDebug("has url!!!\n");
    QList<QUrl> urls = event->mimeData()->urls();
    foreach (QUrl url, urls)
    {
      qDebug("* %s\n", url.toString().toAscii().constData());
    }
  }
  //qDebug(event->mimeData()->text().toAscii().constData() << std::endl;
  event->acceptProposedAction();
}